package com.journaldev.spring.util;

import java.beans.PropertyEditorSupport;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class SimpleDateTimeEditor extends PropertyEditorSupport {
	public SimpleDateTimeEditor(){
        //this.cityDao = cityDao;
    }
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
    	Date date = null;
    	SimpleDateFormat format = new SimpleDateFormat("dd/mm/yyyy");
        java.util.Date parsed = null;
		try {
			parsed = format.parse(text);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        java.sql.Date sql = new java.sql.Date(parsed.getTime());
        setValue(sql);
    }
}
